<!doctype html>
<html>

	<head>
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta charset="UTF-8" />
		<title>管理收货地址</title>
		<link rel="stylesheet" type="text/css" href="css/personalData.css" />
		<link rel="stylesheet" type="text/css" href="css/svg/font.css" />
		<script type="text/javascript">
			window.onload = function() {
				document.documentElement.style.fontSize = document.documentElement.clientWidth / 320 * 20 + 'px';
				window.onresize = function() {
					document.documentElement.style.fontSize = document.documentElement.clientWidth / 320 * 20 + 'px';
				};
			};
		</script>
		<script src="js/jquery-1.11.2.js"></script>
	</head>
	<script>
		$(function(){
			//判断本地储存有没有地址信息
			if(localStorage.dizhi){
				$('#adminAd').show();
				var addrI = localStorage.dizhi.split('-');
 				var str = '<article class="addressI"><div><p id="consigneeName">'+ 
 					addrI[0] +'</p><p id="consigneePhone">'+ 
 					addrI[1] +'</p></div><div id="ReceiptAddress">'+ 
 					addrI[2] +'</div><aside><p><input type="checkbox" class="defaultAddr" /><span>默认地址</span></p>\
 					<a href="javascript:;" id="edit"><i class="icon-file-text2"></i>编辑</a>\
 					<a href="javascript:;" id="delete"><i class="icon-bin"></i>删除</a></aside></article>';
				$('#adminAd').append(str);
			}else{
				$('#adminAd').remove();
			}
		})
	</script>
	<body>
		<!--地址管理header开始-->
		<header class='addbox'>
			<a id="shang"><img src='img/szdz.jpg' /> 管理收货地址</a>
		</header>
		<!--地址管理header结束-->

		<!--地址管理内容开始-->
		<section id="adminAd">
		</section>
		<!--地址管理内容结束-->

		<!--地址管理footer开始-->
		<a href="../1603B-taobao/shouhuodizhi.html">
			<footer class='nthdiv2'>添加新地址</footer>
		</a>
		<!--地址管理footer结束-->
		
		<!--提示盒子开始-->
		<div id="conDelBox"></div>
		<div id="conDel">
			<p></p>
			<a href="javascript:;" id="cencel">取消</a>
			<a href="javascript:;" id="sure">删除</a>
		</div>
		<!--提示盒子结束-->
	</body>
	<script>
	$("#shang").click(function(){
		window.history.back(-1);
		
	})
	
	
		//点击默认地址变色
		$('#adminAd').delegate('.defaultAddr','click',function(){
			if($('.defaultAddr').prop('checked') == true){
				$(this).next().css('color','#FB5707');
			}else{
				$(this).next().css('color','#4A4C4B');
			}
		})
		
		//点击编辑跳转编辑地址页面
		$('#adminAd').delegate('#edit','click',function(){
			window.location.href = 'editAddress.html';
		})
		
		//点击删除当前这条地址
		$('#adminAd').delegate('#delete','click',function(){
			$('#conDelBox').fadeIn(200);
			$('#conDel').fadeIn(200);
			$('#conDel p').text('确认要删除该地址吗？');
			$('#sure').on('click',function(){
				$('#conDelBox').fadeOut(100);
				$('#conDel').fadeOut(100);
				localStorage.removeItem('user_addr');
				$('.addressI').remove();
			})
			$('#cencel').on('click',function(){
				$('#conDelBox').fadeOut(100);
				$('#conDel').fadeOut(100);
			})
		})
		
	</script>
</html>